package com.example.demo.exception;

import com.example.demo.utils.IErrorCode;
import org.springframework.http.HttpStatus;

/**
 *
 * @author c10709
 * @date 2018/7/31
 */
public class RateLimiterException extends RuntimeException {
    private static final long serialVersionUID = 1L;

    private Integer errorCode;

    public Integer getErrorCode() {
        return errorCode;
    }

    public void setErrorCode(Integer errorCode) {
        this.errorCode = errorCode;
    }

    public RateLimiterException(Integer errorCode) {
        super();
        this.errorCode = errorCode;
    }
    public RateLimiterException(IErrorCode errorCode) {
        super(errorCode.getErrorMessage());
        this.errorCode = errorCode.getErrorCode();
    }

    public RateLimiterException(String defaultMessage) {
        super(defaultMessage);
        this.errorCode = HttpStatus.BANDWIDTH_LIMIT_EXCEEDED.value();
    }

    public RateLimiterException(Integer errorCode, String defaultMessage) {
        super(defaultMessage);
        this.errorCode = errorCode;
    }
}
